import gameListApi from "@/api/gameConfig/gameList"
import { getDicts } from "@/api/system/dict/data"
import {
  arrayToObject,
} from "@/utils/ruoyi"
const other = {
  state: {
    allGameList: [],//平台所有游戏
    gameYunyingshangList: [],//游戏运营商列表
    retailDomain:{},//分销网域名
  },

  mutations: {
    SET_ALLGAMELIST: (state, allGameList) => {
      state.allGameList = allGameList
    },
    SET_gameYunyingshangList: (state, YunyingshangList) => {
      state.gameYunyingshangList = YunyingshangList
    },
    SET_retailDomain:(state, retailDomain) => {
      state.retailDomain = retailDomain
    },
  },

  actions: {
    // 获取所有游戏名称
    getGameList({ commit }) {
      gameListApi.getGameList().then(res=>{
        if (res.rows && res.rows.length){
          commit('SET_ALLGAMELIST',res.rows)
        }
        
      })
    },
    // 获取所有游戏运营商
    getGameYYSList({ commit }) {
      gameListApi.getGameYunyingshangList().then(res=>{
        if (res.rows && res.rows.length){
          commit('SET_gameYunyingshangList',res.rows)
        }
        
      })
    },
    // 获取分销网域名
    getRetailDomain({ commit }) {
      getDicts("retailDomain").then(res=>{
        if (res.data && res.data.length) {
          const retailDomain = arrayToObject(res.data, "dictLabel");
          commit('SET_retailDomain',retailDomain)
        }
      })
    },
    
  }
}

export default other
